use std::collections::HashMap;
use std::collections::hash_map::RandomState;
use std::io::Read;

pub fn main(){
    let mut h: HashMap<String, i32> = HashMap::new();
    h.insert("age".to_string(),12);
    h.insert("num".to_string(), 18);

    // rust如何比较引用相等的
    let mut x = "ag".to_string()+"e";
    println!("age value={}", h.get(&x).unwrap_or(&-1));

    let teams  = vec![String::from("Blue"), String::from("Yellow")];
    let initial_scores = vec![10, 50];

    let mut scores: HashMap<_, _> = teams.iter().zip(initial_scores.iter()).collect();
    for (&k,&v) in &scores {
        println!("k:{}, V:{}", k, v);
    }
    println!("value1 = {}", scores.get(&"Blue".to_string()).unwrap_or(&&-1));
    let string = "Blue".to_string();
    scores.insert(&string, &99);
    println!("{:?}", scores);

    let v = h.entry("email".to_string()).or_insert(99);
    println!("h={:?}",h);

    let mut map: HashMap<String, Vec<String>> = HashMap::new();
    map.entry("eng".to_string())
        .or_insert(Vec::new())
        .push("Lily".to_string());
    map.entry("eng".to_string())
        .or_insert(Vec::new())
        .push("Smith".to_string());
    map.entry("Hr".to_string())
        .or_insert(Vec::new())
        .push("John".to_string());
    println!("map={:?}", map);
}